Python/RegEx/String with combination of a and bs/String has a followed by 0 or 1 bs/String has a followed by 0 or 1 bs.py
import re
str = input("Enter a string: ")
rePat = r'ab?'
if re.findall(rePat, str):
print("Valid")
else:
print("Invalid")